package dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

public class Section_InfoImpl implements Section_InfoDao {
	private Connection conn;
	private PreparedStatement section_infoQuery;
	private ResultSet rs;
	@Override
	public List<Section_Info> find(String section_id, String section_name, String info_id, String info_name) {
		List<Section_Info> section_infoList=new ArrayList<Section_Info>();
		try {
			conn=DBcon.getConnection();
			String sql="select * from section_info where section_id='"+section_id+"' or section_name='"+section_name+"' or info_id='"+info_id+"' or info_name='"+info_name+"'";
			section_infoQuery=conn.prepareStatement(sql);
			rs=section_infoQuery.executeQuery();
			while(rs.next()) {
				Section_Info section_info=new Section_Info();
				section_info.setSection_id(rs.getString("section_id"));
				section_info.setSection_name(rs.getString("section_name"));
				section_info.setInfo_id(rs.getString("info_id"));
				section_info.setInfo_name(rs.getString("info_name"));
				section_infoList.add(section_info);
			}
		}catch(Exception e) {
			e.printStackTrace();
		}
		finally {
			DBcon.closeConnection(conn);
			DBcon.closeResult(rs);
			DBcon.closeStatement(section_infoQuery);
		}
		
		return section_infoList;
	}

}
